package me.minecraft.plugin.itemsave.command;

import lombok.Getter;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;

import java.util.Collections;
import java.util.List;

/**
 * @author langle__
 * @version 1.0
 */
@Getter
public abstract class SubCommand {

    public String getPermission() {
        return null;
    }

    public boolean hasPermission(CommandSender sender) {
        if (getPermission() == null) return true;
        return sender.hasPermission(getPermission());
    }

    public void onCommand(CommandSender sender, String[] args) {
        if (sender instanceof Player) {
            onCommand((Player) sender, args);
        } else if (sender instanceof ConsoleCommandSender) {
            onCommand((ConsoleCommandSender) sender, args);
        }
    }

    public void onCommand(Player player, String[] args) {
    }

    public void onCommand(ConsoleCommandSender console, String[] args) {
    }

    public List<String> onTabComplete(CommandSender sender, String[] args) {
        return Collections.emptyList();
    }

}
